package com.tedu.openmedical.duplicate.basic_info.controller;

import com.tedu.openmedical.duplicate.basic_info.pojo.dto.CopySettingsParam;
import com.tedu.openmedical.duplicate.basic_info.pojo.dto.InfoParam;
import com.tedu.openmedical.duplicate.basic_info.pojo.vo.CopySettingsVO;
import com.tedu.openmedical.duplicate.basic_info.pojo.vo.HistoryVO;
import com.tedu.openmedical.duplicate.basic_info.pojo.vo.HospitalInfoVO;
import com.tedu.openmedical.base.response.JsonResult;
import com.tedu.openmedical.duplicate.basic_info.pojo.vo.MailInfoVO;
import com.tedu.openmedical.duplicate.basic_info.service.BasicInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "基础信息管理")
@RestController
@RequestMapping("/v1/duplicate/basic_info")
@Slf4j
public class BasicInfoController {
    @Autowired
    private BasicInfoService basicInfoService;

    @ApiOperation("获取医院基本信息")
    @GetMapping("get_hos_info")
    public JsonResult getHospitalInfo(){
        log.debug("获取医院基本信息");
        HospitalInfoVO hosInfo = basicInfoService.getHosInfo();
        return JsonResult.ok(hosInfo);
    }
    @ApiOperation("获取邮寄基本信息")
    @GetMapping("get_mail_info")
    public JsonResult getMailInfo(){
        log.debug("获取邮寄信息");
        MailInfoVO mailInfo=basicInfoService.getMailInfo();
        return JsonResult.ok(mailInfo);
    }
    @ApiOperation("获取医院信息修改履历")
    @GetMapping("get_hos_history")
    public JsonResult getHosInfoHistory(){
        log.debug("获取医院信息修改履历");
        List<HistoryVO> historyVO=basicInfoService.getHosInfoHistory();
        return JsonResult.ok(historyVO);
    }
    @ApiOperation("获取邮寄信息修改履历")
    @GetMapping("get_mail_history")
    public JsonResult getMailInfoHistory(){
        log.debug("获取邮寄信息修改履历");
        List<HistoryVO> historyVO=basicInfoService.getMailInfoHistory();
        return JsonResult.ok(historyVO);
    }
    @ApiOperation("修改医院基本信息")
    @PostMapping("update_hos_info")
    public JsonResult updateHospitalInfo(InfoParam infoParam){
        log.debug("修改医院基本信息，infoParam:{}", infoParam);
        basicInfoService.updateHosInfo(infoParam);
        return JsonResult.ok();
    }
    @ApiOperation("修改邮寄信息")
    @PostMapping("update_mail_info")
    public JsonResult updateMailInfo(InfoParam infoParam){
        log.debug("修改邮寄信息，infoParam:{}", infoParam);
        basicInfoService.updateMailInfo(infoParam);
        return JsonResult.ok();
    }
    @ApiOperation("获取复印配置")
    @GetMapping("get_copy_settings")
    public JsonResult getCopySettings(){
        log.debug("获取复印配置");
        CopySettingsVO settings = basicInfoService.getCopySettings();
        return JsonResult.ok(settings);
    }
    @ApiOperation("修改复印配置")
    @PostMapping("update_copy_settings")
    public JsonResult updateCopySettings(CopySettingsParam param){
        log.debug("修改复印配置，param:{}", param);
        basicInfoService.updateCopySett(param);
        return JsonResult.ok();
    }
}
